package com.lipaluma.xml.mapping;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import com.lipaluma.field.mapper.AutomaticFieldMapper;
import com.lipaluma.field.mapper.FieldMapper;

@XmlRootElement(name=XmlColumnMapping.COLUMN)
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlColumnMapping extends AbstractXmlFieldMapping {
	public static final String COLUMN = "column";
	
	@XmlAttribute
	private Integer index;
	@XmlAttribute
	private String name;
	@XmlAttribute(name="index-out")
	private Integer indexOut;
	@XmlAttribute
	private Integer length;

	@XmlAttribute
	private Class<? extends FieldMapper> with;

	public Integer getIndex() {
		return index;
	}
	public String getName() {
		return name;
	}
	public Integer getIndexOut() {
		return indexOut;
	}
	public Integer getLength() {
		return length;
	}
	
	@Override
	public boolean isMultiple() {
		return false;
	}
	@Override
	public Class<? extends FieldMapper> with() {
		if(with == null)
			return AutomaticFieldMapper.class;
		return with;
	}
}
